<template>
	<view class="box">
		<uNavbar title="开通钱包" bgColor="transparent"></uNavbar>
		<view class="info">
			<view class="info_item">
				<text>姓名</text>
				<input type="text" v-model.trim="name"  disabled  placeholder="请输入真实姓名" />
			</view>
			<view class="info_item">
				<text>身份证号</text>
				<input type="idcard"  v-model.trim="idCard" disabled  placeholder="请输入身份证号"/>
			</view>
			<view class="info_item">
				<text>手机号</text>
				<input type="idcard"   v-model.trim="phone"   placeholder="请输入本人实名手机号"/>
			</view>
		</view>

		<view class="tip_wrap">
			<rich-text  class="s" :nodes="rule"></rich-text>
			<view class="log_out flex_c bgTaggle"  @click="isConfirm">
				<image class="highlights"  src="../../static/image/mask.png" ></image>
				<text>确认</text>
			</view>
		</view>
	</view>

</template>

<script>
	import {myAccount,openingAccount,bindCard} from "../../api/wallet.js"
	export default {
		data() {
			return {
				name:'',
				idCard:'',
				phone:'',
				wallet_type:'',
				check:false,
				rule:"",
				type:""
			}
		},

		onLoad(opitons) {
			this.type=opitons.type
			// this.type=uni.getStorageSync("bankType")
			console.log(this.type)
			this.getrule()
			// this.isMyAccount()
		},
		onShow() {
			this.isMyAccount()
		},
		methods: {
			getrule(){
				bindCard().then(res=>{
					this.rule=res.data.content
				})
			},
			// 用户信息
			isMyAccount() {
				myAccount().then(res => {
					console.log(res)
					if (res.code == 1) {
						this.name = res.data.member_real.real_name
						// this.phone = res.data.member_real.phone
						this.idCard = res.data.member_real.id_num
						if(this.type==2&&res.data.sd_is_switch==1){
							uni.navigateTo({
								url:"/pagesMy/mywallet/newmywallet"
							})
						}
					}
				})
			},
			//开户
			isOpening() {
				if (!uni.$u.test.mobile(this.phone)) {
					uni.$u.toast('手机号格式错误');
				}else{
					openingAccount({
							phone:this.phone,
							wallet_type:this.type,		
					}).then(res => {
							if(this.type==1&&res.code == 1){
								setTimeout(()=>{
									uni.navigateTo({
										url:"/pagesMy/mywallet/newmywallet"
									})
								},1000)
								uni.$u.toast(res.msg);
							}else if(this.type==2 &&res.code == 1){
								uni.$u.toast("正在跳往杉德支付");
								
								// #ifdef APP
									uni.setStorageSync("url",res.data.sd_url)
									uni.navigateTo({
										url:"/pagesMy/mycollection/webview"
									})
								// #endif
								// #ifdef H5
									window.location.href=res.data.sd_url
								// #endif
								console.log(res)
							}else{
								uni.$u.toast(res.msg);
							}
						
					})
				}	
			},
			isConfirm(){
				this.isOpening()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		width: 750rpx;
		height: 100vh;
		background-color:#E0DDDA;
	}
	.info{
		width: 750rpx;
		// height: 200rpx;
		
		.info_item{
			width: 630rpx;
			height: 80rpx;
			margin: 0 auto;
			margin-top: 50rpx;
			border-bottom: 2rpx solid rgba(255,255,255,0.15);
			display: flex;
			>text{
				width: 130rpx;
				font-weight: 400;
				font-size: 32rpx;
				color: #333;
			}
			>input{
				font-weight: 300;
				font-size: 32rpx;
				color: #666;
				margin-left: 56rpx;
			}
		}
	}
	.idcard_wrap{
		width: 630rpx;
		height: 300rpx;
		margin: 0 auto;
		margin-top: 50rpx;
		.idcard_tit{
			font-weight: 400;
			font-size: 32rpx;
			color: #FFFFFF;
		}
		.image_wrap{
			margin-top: 38rpx;
			width: 630rpx;
			height: 162rpx;
			display: flex;
			justify-content: space-between;
			.image_item{
				width: 288rpx;
				height: 162rpx;
				background: #B8A185;
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				>image{
					width: 288rpx;
					height: 162rpx;
					background: #B8A185;
					border-radius: 16rpx 16rpx 16rpx 16rpx;
				}
			}
		}
	}
	.tip_wrap{
		// position: fixed;
		// bottom: 250rpx;
		// left: 50%;
		// transform: translateX(-50%);
		width: 700rpx;
		margin: 0 auto;
		margin-top: 100rpx;
		min-height: 600rpx;
		.tip_tit{
			font-weight: 400;
			font-size: 26rpx;
			color: #666;
			margin-bottom: 22rpx;
		}
		>text{
			
			font-weight: 400;
			font-size: 26rpx;
			color: #666;
		}
	}
	.log_out {
		position: relative;
		width: 92%;
		margin: 150rpx auto 0;
	}

	.log_out>text {
		text-align: center;
		width: 100%;
		background: linear-gradient( 90deg, #AB8E68 0%, #D7BA93 100%);
		color: #ffffff90;
		font-size: 32rpx;
		padding: 20rpx 0;
		border-radius: 40rpx;
	}

	.bgTaggle>text {
		width: 100%;
		text-align: center;
		font-size: 32rpx;
		padding: 20rpx 0;
		border-radius: 40rpx;
		color: #ffffff !important;
		background: linear-gradient( 90deg, #AB8E68 0%, #D7BA93 100%);
	}
	.s{
		color: #666;
		margin: 0 auto;
	}
</style>